﻿/*
* ==============================================================================
*
* Filename: crm_userroles_utl
* Description: crm_userroles_utl
*
* Version: 1.0
* Created: 2020/8/25 18:00:02
* Compiler: Visual Studio 2019
*
* Author: Administrator
* Company: freelancer
*
* ==============================================================================
*/

namespace db_util {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.Threading.Tasks;
	using db_model;
	using MySql.Data.MySqlClient;

	public class crm_userroles_util {
		public static crm_userroles_model GetModel(int ID) {
			var model = new crm_userroles_model();
			string sql = "select ID,RoleName,State from crm_userroles where ID=?ID limit 1";
			MySqlParameter[] parameters = {
	 new MySqlParameter("?ID", MySqlDbType.Int32)
				};
			parameters[0].Value = ID;
			using (var dr = mysql_helper.GetDataReader(sql, parameters)) {
				if (dr.Read()) {
					model.ID = int.Parse(dr["ID"].ToString() == "" ? "-1" : dr["ID"].ToString());
					model.RoleName = dr["RoleName"].ToString();
					model.State = int.Parse(dr["State"].ToString() == "" ? "-1" : dr["State"].ToString());
				}
			}
			return model;
		}

	}
}